package com.loongtech.bi.entity.log.core;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

import com.loongtech.core.gen.GenInnerK;
import com.loongtech.core.jpa.entity.EntityBase;

@MappedSuperclass
@GenInnerK
public abstract class EntityLogBase{
	public static final String SERVER_ALL = "0";				//全服统计标识
	public static final String CHANNEL_ALL = "0";		//全渠道计标识
	public static final String LOCATION_ALL = "0";		//全地域计标识
	
	public abstract Serializable id();
	
	//每种日志都记录时间戳和日期是合理的
	private long timestamp;
	@Column(length = 10, nullable = true)
	private String date;
	
	public long getTimestamp() {
		return timestamp;
	}
	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}
	public String getDate() {
		return date;
	}
	public void setDate(String date) {
		this.date = date;
	}
	
	@Override
	public boolean equals(Object other) {
		if(this == other) {
			return true;
		}
		if(!(other instanceof EntityBase)) {
			return false;
		}
		EntityBase castOther = (EntityBase) other;
		return new EqualsBuilder().append(this.id(), castOther.id()).isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(this.id()).toHashCode();
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this).append("id", this.id()).toString();
	}
	public static class K {
		public static final String timestamp = "timestamp";
		public static final String date = "date";
		
		//timestamp, date, 
		public static java.util.List<String> toList() {
			java.util.List<String> list = new java.util.ArrayList<>();
			list.add(timestamp);
			list.add(date);
			return list;
		}
	}
}